<?php
include('../../__global.php');
include(SERVER_ROOT_PATH.'/include/config/ml_catelog.php');

class aj_get_notice_count extends ml_controller
{

    public function initParam()
    {

    }
    public function checkParam()
    {
        $this->check_referer();
        if(!$this->check_permission(ML_PERMISSION_LOGIN_ONLY)) {
            return $this->api_output(ML_RCODE_NOLOGIN);
        }
        else if(!$this->check_permission(ML_PERMISSION_LOGIN_CANWRITE)) {
            return $this->api_output(ML_RCODE_NOACTIVE);
        }
    }
    public function main()
    {
        $oRdsNotice = new ml_model_rdsNotice();
        $aRs = $oRdsNotice->getNotice($this->__visitor['uid']);
        
        $aOutput = array(
            'is_pubnotice' => time() < $aRs[ml_model_rdsNotice::NTCTYPE_PUBLICNOTICE] ? true : false,
            'sysntc' => intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDSYSNOTICE  ]),
            'fans' => intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDFANS ]),
            'cmt' => intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDCOMMENT  ]),
            'atme' => intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDATME  ]),
            'like' => intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDATTITUDE  ]),
            'total' =>  intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDSYSNOTICE  ])
                     + intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDFANS ])
                     + intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDCOMMENT  ])
                     + intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDATME  ])
                     + intval($aRs[ml_model_rdsNotice::NTCTYPE_ADDATTITUDE  ])
        );
        
        
        $this->api_output(ML_RCODE_SUCC , $aOutput);
    }
    
}
new aj_get_notice_count();